<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="../links.jsp"></jsp:include>
<script type="text/javascript">
	$(
			function() { 
				var admin_userAdd_form;
				admin_userAdd_form = $('#admin_userAdd_form').form({
					url : getRootPath() + '/userAction/reg.do',
					success : function(r) {
						r = $.parseJSON(r);//将标准json转成obj
						if (r && r.success) {
							$.messager.show({
								title : '提示',
								msg : '添加成功',
								showType : 'show'
							});
						} else {
							$.messager.alert('提示', '用户已存在');
						}
					}
				});
				admin_user_add_fun = function() {
					if ($('#name1').val() == null || $('#name1').val() == ""
							|| $('#pwd1').val() == "" || $('#pwd1').val() == null) {
						$.messager.alert('提示', '请输入用户名密码');
						return false;
					}
					if ($('#pwd1').val() == $('#pwd2').val()) {
						if (($('#pwd1').val() != "" && $('#pwd1').val() != null)) {
							$('#admin_userAdd_form').submit();
						}
					} else {
						$.messager.alert('提示', '两次密码输入不一致');
						$("input[name='pwd']").val('');
						$("input[name='repwd']").val('');
						return false;
					}
					return true;
				}
				var userDel_form;
				userDel_form = $('#userDel_form').form({
					url : getRootPath() + '/userAction/delete.do',
					success : function(r) {
						r = $.parseJSON(r);//将标准json转成obj
						if (r && r.success) {
							$.messager.show({
								title : '提示',
								msg : '删除成功',
								showType : 'show'
							});
						} else {
							$.messager.alert('提示', '用户不存在');
						}
					}
				});
				user_del_fun = function() {
					if ($('#id3').val() == null || $('#id3').val() == "") {
						$.messager.alert('提示', '请输入编号');
						return false;
					} else {
						$('#userDel_form').submit();
					}
					return true;
				}

			})
</script>
<div id="admin_userAdd" style="position: absolute; left: 32%; top: 20%;">
	<form id="admin_userAdd_form" method="post">
		<table cellpadding="5">
			<tr>
				<th>用户名</th>
				<td><input id="name1" class="easyui-validatebox" type="text" name="name"
					data-options="novalidate:true,missingMessage:'请输入用户名'"></input></td>
			</tr>
			<tr>
				<th>密码</th>
				<td><input id="pwd1" class="easyui-validatebox" name="pwd" type="password"
					data-options="novalidate:true,missingMessage:'请输入密码'" /></td>
			</tr>
			<tr>
				<th>确认密码</th>
				<td><input id="pwd2" class="easyui-validatebox" name="repwd" type="password"
					data-options="novalidate:true,missingMessage:'重复输入密码'" /></td>
			</tr>
			<tr>
				<th>用户类型</th>
				<td><select class="easyui-combobox" name="type" style="width: 175px;" panelHeight="42px">
						<option value="admin">管理员</option>
							<option value="user">普通用户</option>
				</select></td>
			</tr>
			<tr>
				<td colspan="2"><span><a href="javascript:;" class="easyui-linkbutton" style="width: 288px;"
						onclick="admin_user_add_fun()"><font color="green">添加 用户</font></a></span></td>
			</tr>
		</table>
	</form>
	<form id="userDel_form" action="">
		<table>
			<tr>
				<th>输入要删除用户的编号(*)</th>
			</tr>
			<tr>
				<td><input id="id3" style="width: 288px;" class="easyui-validatebox" type="text" name="id"
					data-options="novalidate:true"></input></td>
			</tr>
			<tr>
				<td colspan="2"><span><a href="javascript:;" class="easyui-linkbutton" style="width: 288px;"
						onclick="user_del_fun()"><font color="red">删除 用户</font></a></span></td>
			</tr>
		</table>
	</form>
</div>